package com.example.demo;

import com.example.demo.bean.User;
import com.example.demo.config.Configer;
import com.example.demo.service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

@SpringBootApplication
public class DemoApplication {

//    public static void main(String[] args) {
//        SpringApplication.run(DemoApplication.class, args);
//    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Configer.class);
        UserService userService = context.getBean(UserService.class);
        Configer configer = context.getBean(Configer.class);
        User user1 = context.getBean(User.class);
        User user2 = context.getBean(User.class);
        userService.save(null);
        User user3 = configer.getUser();
        User user4 = configer.getUser();
        System.out.println(user1 == user2);
        System.out.println(user3 == user4);
        context.close();
    }
}
